<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>导航</title>
		<link rel="stylesheet" href="../../resources/css/common.css" />
		<!--<script type="text/javascript" src="../../resources/js/jquery-1.11.1.min.js"></script>-->
		<script type="text/javascript" src="../../resources/layui/layui.js"></script>
		<!--<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>-->
	</head>

	<body>

		<div class="header">
			<a class="home" href="/index.jsp" title="xxit在线学习平台">
				<!--<img src="resources/images/logo_new.png" alt="">-->
			</a>
			<ul class="menu">
	<!-- 
				<li class="item">
					<a href="/index.jsp">首页</a>
				</li>
				<li class="item">
					<a href="/pages/course/course.jsp">课程</a>
				</li>
	-->
				<li class="item">
					<a href="/pages/question/question.jsp">提问</a>
				</li>
				<li class="item">
					<a href="/pages/article/article.jsp">文章</a>
				</li>
				<li class="item">
					<a href="/pages/integrlmall/integrlmall.jsp">积分商城</a>
				</li>
				<li class="item">
					<a href="/pages/user/userdetails.jsp">个人中心</a>
				</li>
			</ul>
			<div class="search-area">
				<input class="search-input" type="text">
				<div class="search-btn"><i class="icon icon-search">&#xe63d;</i></div>
			</div>
			<ul class="header-unlogin clearfix">
				<c:choose>

					<c:when test="${empty sessionScope.userName}">
						<li class="login">
							<a href="#" class="userlogin">登录</a>
							/
							<a href="#" class="userregister">注册</a>
						</li>
					</c:when>
					<c:otherwise>
						<li class="login">
							欢迎回来:
						</li>
						<li class="login" >
							<div class="headname">
								${sessionScope.userName}
							</div>
							<a href="/logout.action" class="">退出</a>
						</li>
					</c:otherwise>

				</c:choose>

			</ul>
		</div>
		<!--导航高亮-->
		<script>
			$(".header").css("position", "fixed");
			$(".header").css("background", "#fff url(https://iazuresky.com/img/nav.jpg) repeat-x scroll 0 100%")
			var urlstr = location.href;
			var index1 = urlstr.lastIndexOf("\/");
			/* alert("地址栏："+urlstr.substring(index1 + 1, urlstr.length-4)); */
			urlstr = urlstr.substring(index1 + 1, urlstr.length - 4);
			/* alert(urlstr); */
			$(".menu .item a").each(function() {
				var str = $(this).attr('href');
				var index = str.lastIndexOf("\/");
				str = str.substring(index + 1, str.length - 4);
				if(urlstr.indexOf(str) != -1 && $(this).attr('href') != '') {
					$(this).css("background", "#1e73be");
					$(this).css("color", "white");
				}
			});
			layui.use('layer', function() {
				var layer = layui.layer;
				$('.userlogin').on('click', function() {
					var index = layer.open({
						type: 2,
						title: '注册/登陆',
						shadeClose: true, //点击遮罩关闭层
						area: ['420px', '380px'],
						content: '	/pages/relogin/login.jsp'
					});
				});
				$('.userregister').on('click', function() {
					layer.open({
						type: 2,
						title: '注册/登陆',
						shadeClose: true, //点击遮罩关闭层
						area: ['430px', '430px'],
						content: '/pages/relogin/register.jsp'
					});
				});
			});
		</script>
	</body>

</html>